﻿using HRMSystem.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace HRMSystem.Wpf.DepartmentPages
{
    /// <summary>
    /// Interaction logic for editPage1.xaml
    /// </summary>
    public partial class EditPage:Page
    {
        private static EditPage instance;
        List<DepartmentDetails> list;
        DepartmentDetails editDetails;

        public EditPage()
        {
            InitializeComponent();

            list = DBServices.DepartmentService.findDeparmentDetails();

            name.Text = list.ElementAt(0).NAME;

           
        }
        public static EditPage Instance
        {
            get 
            {
             if(instance==null)
             {
                 instance = new EditPage();
             }
             return instance;
            }
        
        }

        private void Save_Button_Click_1(object sender, RoutedEventArgs e)
        {
            editDetails = new DepartmentDetails();

            editDetails.NAME = name.Text;
            DBServices.DepartmentService.updateDepartmentDetails(editDetails);

            ViewPage.NullInstance();
            DepartmentPage.Instance.ContentFrame.Content = ViewPage.Instance;
            EditPage.NullInstance();

        }

        private static void NullInstance()
        {
            instance = new EditPage();
        }

        private void Cancel_Button_Click_1(object sender, RoutedEventArgs e)
        {
            DepartmentPage.Instance.ContentFrame.Content = ViewPage.Instance;
        }



       
    }
}
